import Base from 'models/base';

import SystemUtil from 'utils/systemUtil';

export default class CouponData extends Base {
  constructor(coupon) {
    super();

    this.keyId = SystemUtil.getId();
    this.id = coupon.id;
    this.stockId = coupon.stockId;
    this.shopName = coupon.shopName;
    this.description = coupon.description;
    this.rate = coupon.couponGot;
    this.headImg = coupon.headImg;
    this.branchId = coupon.branchId;
    this.partnerId = coupon.partnerId;

    let money = coupon.couponAmount;
    this.money = money / 100;

    let fullMoney = coupon.transactionMinimum;
    this.fullMoney = fullMoney / 100;
  }

  getShopData() {
    let partnerId = this.partnerId;
    if (partnerId !== null) {
      return {
        partnerId
      };
    }

    return {
      branchId: this.branchId
    };
  }
}
